<?php
namespace App\Model\Appfc114;

//use PhalApi\Model\NotORMModel as NotORM;
use Illuminate\Database\Eloquent\Model as Model;
use Illuminate\Database\Capsule\Manager as DB;

class Project extends Model {

    protected $table = "fc_project";
    public $timestamps = false;


    public function getDetail($id, $field ="id"){
        $row = $this
            ->where($field,$id)
            ->first();
        return $row;
    }

    public function getListItems($where,$whereRaw, $limitdata, $order) {
        //如需打印sql 需开启DB执行日志
        // DB::connection()->enableQueryLog();
        $data = $this
            ->where($where)
            ->whereRaw($whereRaw)
            ->orderByRaw($order)
            ->skip($limitdata["offset"])
            ->take($limitdata["limit"])
            ->get();
        //打印sql
        // print_r(DB::getQueryLog());exit;
        return $data;
    }


    public function getListTotal($state="") {
        $total = $this->where($state)->count();
        return intval($total);
    }
}
